package com.niezhiliang.springboot.rabbitmq.customer.consumer;

import com.niezhiliang.springboot.rabbitmq.common.annotation.MQCutHandler;
import com.niezhiliang.springboot.rabbitmq.common.domain.Order;
import com.niezhiliang.springboot.rabbitmq.common.util.MessageUtils;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author NieZhiLiang
 * @Email nzlsgg@163.com
 * @Date 2019/1/24 上午10:29
 */
@RabbitListener(
        bindings = @QueueBinding(                    //数据是否持久化
                value = @Queue(value = "order-queue",durable = "true"),
                exchange = @Exchange(name = "order-exchange",
                        durable = "true",type = "topic",ignoreDeclarationExceptions = "true"),
                key="order.*"
        )
)
@Component
public class OrderReceiver  implements MessageUtils.AckMessageListener
{




    public void handler( Order order)  {
        System.out.println("----收到消息，开始消费-----");
        System.out.println("d订单id："+order.getId());
        int i = 1/0;
        /**
         *  取值为 false 时，表示通知 RabbitMQ 当前消息被确认
         *  如果为 true，则额外将比第一个参数指定的 delivery tag 小的消息一并确认
         */
        System.out.println("--------消费完成--------");
    }

}
